<template>
    <!-- <van-nav-bar title="标题" /> -->
    <van-nav-bar title="会员登录" left-text="" left-arrow @click-left="onBack" />

    <van-form @submit="onSubmit">
        <van-cell-group inset>

            <van-field 
                v-model="username" 
                name="用户名" 
                 placeholder="请输入手机号"
                :rules="[{ required: true, message: '请输入手机号' }]" />

            <van-field
                v-model="sms"
                center
                clearable
                placeholder="请输入短信验证码"
            >
                <template #button>
                    <!-- <van-image
                        width="80"
                        height="35"
                        :src="code"
                        /> -->
                    <img style="width: 60px;height: 30px;" src="../assets/code.png" alt="">

                </template>
            </van-field>

            <van-field
                v-model="sms"
                center
                clearable
                placeholder="请输入短信验证码"
            >
                <template #button>
                <!-- <van-button size="small" type="primary">发送验证码</van-button> -->
                    <span class="code">发送验证码</span>
                </template>
            </van-field>


            <van-field v-model="password" type="password" name="密码" label="密码" placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]" />


        </van-cell-group>
        <div style="margin: 16px;">
            <van-button round block type="primary" native-type="submit">
                提交
            </van-button>
        </div>
    </van-form>
</template>

<script setup>
import { ref } from 'vue';
import { RouterLink,useRouter } from 'vue-router';
import { showSuccessToast } from 'vant';


const router = useRouter();

const username = ref('');
const password = ref('');
const onSubmit = (values) => {
    showSuccessToast('登录成功！');
    router.push("/");
};

import code from "../assets/code.png";

const onBack=()=>{
    router.back();
}
</script>
<style scoped>
.code{color: #f00;}
</style>
<style>
body {
    --van-nav-bar-icon-color: #f00;
    --van-nav-bar-arrow-size: 22px;
}
</style>